import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { IPage, ICommunityMember } from "./types";

/* 查询社团成员列表 */
export function getPageCommunityMemberAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<ICommunityMember[]>> {
  return request({
    url: "/communityUser/page",
    method: "get",
    params: queryParams,
  });
}
/* 根据id查询社团成员对象 */
export function getFormCommunityMemberAPI(
  id: number
): AxiosPromise<ICommunityMember> {
  return request({
    url: `/communityUser/${id}/form`,
    method: "get",
  });
}

/**
 * 添加社团成员
 *
 * @param data
 */
export function addCommunityMemberAPI(data: any) {
  return request({
    url: "/communityUser",
    method: "post",
    data: data,
  });
}

/**
 * 修改社团成员
 *
 * @param id
 * @param data
 */
export function updateCommunityMemberAPI(id: number, data: ICommunityMember) {
  return request({
    url: "/communityUser/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除社团成员
 *
 * @param ids
 */
export function deleteCommunityMemberAPI(ids: number) {
  return request({
    url: "/communityUser/" + ids,
    method: "delete",
  });
}

/* 同意用户加入社团 */
export function updateStatusCommunityMemberAPI(id: number) {
  return request({
    url: "/communityUser/update/status/" + id,
    method: "put",
  });
}
